package com.kamistoat.meimeichat.meimeichatclient.socket.handlers;

import com.kamistoat.meimeichat.meimeichatclient.application.UIServiceConnector;
import com.kamistoat.meimeichat.meimeichatclient.socket.NettyClientBizHandler;
import com.kamistoat.meimeichat.meimeichatui.view.chat.IChatMethod;
import com.kamistoat.meimeichatserveraggrement.protocol.friend.AddFriendResponse;
import io.netty.channel.Channel;
import javafx.application.Platform;

/**
 * 客户端处理服务器返回的 添加好友响应
 */
public class AddFriendHandler extends NettyClientBizHandler<AddFriendResponse> {

    public AddFriendHandler(UIServiceConnector uiServiceConnector) {
        super(uiServiceConnector);
    }

    @Override
    public void channelRead(Channel channel, AddFriendResponse addFriendResponse) {
        IChatMethod chat = uiServiceConnector.getIChatMethod();
        Platform.runLater(() -> {
            chat.addFriendUser(true, addFriendResponse.getFriendId(), addFriendResponse.getFriendNickName(), addFriendResponse.getFriendHead());
        });
    }
}
